package com.ding.listener;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ActivitiListener implements ExecutionListener,TaskListener,ActivitiEventListener{

	private static final long serialVersionUID = -2922228543278525210L;
	
	@Autowired
	RuntimeService runtimeService;
	
	@Autowired
	TaskService taskService;
	
	@Override
	public void notify(DelegateExecution execution) {

		
		

		/*System.out.println("活动名称:"+execution.getCurrentActivityName()+"  事件类型:"+execution.getEventName());
		System.out.println();
*/
		//throw new BpmnError("error","执行出现错误");//抛出错误
		
		/*Map<String, Object> map = execution.getVariables();
		for (String key : map.keySet()) {
			System.out.println(key);
		}*/
	}


	@Override
	public void notify(DelegateTask delegateTask) {
		System.out.println("任务名称:"+delegateTask.getName()+"  事件类型:"+delegateTask.getEventName());
		System.out.println();
		
	}


	@Override
	public void onEvent(ActivitiEvent event) {
	}


	@Override
	public boolean isFailOnException() {
		return false;
	}
	

}
